package com.shuai.jit.mapper.vo;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shuai.jit.entity.vo.VoArticle;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author joker
 * @since 2021-01-21
 */

@Mapper
@Repository
public interface VoArticleMapper extends BaseMapper<VoArticle> {


    @Select("select a.id,user_id,article_context,article_views,article_good,article_bad,article_star,article_title,\n" +
            "article_image,a.gmt_create,a.gmt_modified,username,user_img\n" +
            " from article a left join user u on user_id=u.id where u.id=#{userId} and a.is_delete=0")
    VoArticle selectByUserId(String userId);

    @Select("select a.id,user_id,article_context,article_views,article_good,article_bad,article_star,article_title,\n" +
            "article_image,a.gmt_create,a.gmt_modified,username,user_img\n" +
            " from article a left join user u on user_id=u.id  where a.is_delete=0 ")
    IPage<VoArticle> selectAll(IPage page);


    @Select("select a.id,user_id,article_context,article_views,article_good,article_bad,article_star,article_title,\n" +
            "article_image,a.gmt_create,a.gmt_modified,username,user_img\n" +
            " from article a left join user u on user_id=u.id where a.id=#{id}  and a.is_delete=0")
    VoArticle selectByArticleId(String id);

}
